﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;
using CrystalDecisions.CrystalReports.Engine;

namespace workflowMVC.AspNetForms
{
    public partial class DocForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string Kind = HttpContext.Current.Session["Report_Kind"].ToString();
            DocumentView.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
            if (Kind == "ConfirmStudentForm")
            {
                ConfirmStudentForm f = new ConfirmStudentForm();
                string Name = HttpContext.Current.Session["Report_Name"].ToString();
                string NumCode = HttpContext.Current.Session["Report_NumCode"].ToString();
                string Birthday = HttpContext.Current.Session["Report_Birthday"].ToString();
                string Address = HttpContext.Current.Session["Report_Address"].ToString();
                string StudyClass = HttpContext.Current.Session["Report_Class"].ToString();
                string StartYear = HttpContext.Current.Session["Report_StartYear"].ToString();
                string TimeLast = HttpContext.Current.Session["Report_TimeLast"].ToString();
                string EduMode = HttpContext.Current.Session["Report_EduMode"].ToString();
                string SYear = HttpContext.Current.Session["Report_SYear"].ToString();
                string Reason = HttpContext.Current.Session["Report_Reason"].ToString();
                string Department = HttpContext.Current.Session["Report_Department"].ToString();

                f.SetParameterValue("Name", Name);
                f.SetParameterValue("NumCode", NumCode);
                f.SetParameterValue("Birthday", Birthday);
                f.SetParameterValue("Address", Address);
                f.SetParameterValue("Class", StudyClass);
                f.SetParameterValue("StartYear", StartYear);
                f.SetParameterValue("TimeLast", TimeLast);
                f.SetParameterValue("EduMode", EduMode);
                f.SetParameterValue("SYear", SYear);
                f.SetParameterValue("Reason", Reason);
                f.SetParameterValue("Department", Department);
                Session["Report_Name"] = "";
                Session["Report_NumCode"] = "";
                Session["Report_Birthday"] = "";
                Session["Report_Address"] = "";
                Session["Report_Class"] = "";
                Session["Report_StartYear"] = "";
                Session["Report_TimeLast"] = "";
                Session["Report_EduMode"] = "";
                Session["Report_SYear"] = "";
                Session["Report_Reason"] = "";
                Session["Report_Department"] = "";

                DocumentView.ReportSource = f;
            }
            else if (Kind == "StudentCardForm")
            {
                StudentCardForm f = new StudentCardForm();
                string Name = HttpContext.Current.Session["Report_Name"].ToString();
                string NumCode = HttpContext.Current.Session["Report_NumCode"].ToString();
                string Birthday = HttpContext.Current.Session["Report_Birthday"].ToString();
                string EduMode = HttpContext.Current.Session["Report_EduMode"].ToString();
                string SYear = HttpContext.Current.Session["Report_SYear"].ToString();
                string Reason = HttpContext.Current.Session["Report_Reason"].ToString();
                string Department = HttpContext.Current.Session["Report_Department"].ToString();

                f.SetParameterValue("Name", Name);
                f.SetParameterValue("NumCode", NumCode);
                f.SetParameterValue("Birthday", Birthday);
                f.SetParameterValue("EduMode", EduMode);
                f.SetParameterValue("SYear", SYear);
                f.SetParameterValue("Reason", Reason);
                f.SetParameterValue("Department", Department);
                Session["Report_Name"] = "";
                Session["Report_NumCode"] = "";
                Session["Report_Birthday"] = "";
                Session["Report_EduMode"] = "";
                Session["Report_SYear"] = "";
                Session["Report_Reason"] = "";
                Session["Report_Department"] = "";

                DocumentView.ReportSource = f;
            }
            else if (Kind == "ExcemptTuitionForm")
            {
                ExcemptTuitionForm f = new ExcemptTuitionForm();                

                string Name = HttpContext.Current.Session["Report_Name"].ToString();
                string NumCode = HttpContext.Current.Session["Report_NumCode"].ToString();
                string Birthday = HttpContext.Current.Session["Report_Birthday"].ToString();
                string Department = HttpContext.Current.Session["Report_Department"].ToString();
                string Hometown = HttpContext.Current.Session["Report_Hometown"].ToString();
                string ParentName = HttpContext.Current.Session["Report_ParentName"].ToString();
                string Street = HttpContext.Current.Session["Report_Street"].ToString();
                string Ward = HttpContext.Current.Session["Report_Ward"].ToString();
                string District = HttpContext.Current.Session["Report_District"].ToString();
                string Province = HttpContext.Current.Session["Report_Province"].ToString();
                string Type = HttpContext.Current.Session["Report_Type"].ToString();
                string StudyClass = HttpContext.Current.Session["Report_Class"].ToString();

                string SYear = HttpContext.Current.Session["Report_SYear"].ToString();
                string StartYear = HttpContext.Current.Session["Report_StartYear"].ToString();
                string TimeLast = HttpContext.Current.Session["Report_TimeLast"].ToString();

                string Tuition = HttpContext.Current.Session["Report_Tuition"].ToString();
                string Fault = HttpContext.Current.Session["Report_Fault"].ToString();

                f.SetParameterValue("Class", StudyClass);
                f.SetParameterValue("Name", Name);
                f.SetParameterValue("NumCode", NumCode);
                f.SetParameterValue("Birthday", Birthday);
                f.SetParameterValue("Department", Department);
                f.SetParameterValue("Hometown", Hometown);
                f.SetParameterValue("ParentName", ParentName);
                f.SetParameterValue("Street", Street);
                f.SetParameterValue("Ward", Ward);
                f.SetParameterValue("District", District);
                f.SetParameterValue("Province", Province);
                f.SetParameterValue("Type", Type);
                f.SetParameterValue("SYear", SYear);
                f.SetParameterValue("StartYear", StartYear);
                f.SetParameterValue("TimeLast", TimeLast);
                f.SetParameterValue("Tuition", Tuition);
                f.SetParameterValue("Fault", Fault);

                Session["Report_Class"] = "";
                Session["Report_Name"] = "";
                Session["Report_NumCode"] = "";
                Session["Report_Department"] = "";
                Session["Report_Birthday"] = "";
                Session["Report_Hometown"] = "";
                Session["Report_ParentName"] = "";
                Session["Report_Street"] = "";
                Session["Report_Ward"] = "";
                Session["Report_District"] = "";
                Session["Report_Province"] = "";
                Session["Report_Type"] = "";
                Session["Report_SYear"]= "";
                Session["Report_StartYear"]= "";
                Session["Report_TimeLast"] = "";

                DocumentView.ReportSource = f;

            }
            //Session["Report_Kind"] = "";
        }
    }
}